package com.shengruan.admin.action;

import java.io.IOException;

import javax.servlet.ServletException;

import com.shengruan.admin.jdbc.ContentJdbc;
import com.shengruan.admin.vo.Content;
import com.shengruan.common.BaseAction;

public class ContentAction extends BaseAction{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	ContentJdbc contentJdbc =(ContentJdbc)this.getJdbc(ContentJdbc.class);
	/**
	 * 根据ID获得
	 * @param request
	 * @param response
	 * @throws ServletException
	 * @throws IOException
	 */
	public void getById() throws Exception 
	{
		int id = Integer.parseInt(input("id"));
		Content content = contentJdbc.getById(id);
		setRequest("content", content);
		this.forward("/admin/article/content.jsp");
	}

	/***
	 * 编辑完毕
	 * @param request
	 * @param response
	 * @throws ServletException
	 * @throws IOException
	 */
	public void update() throws Exception 
	{
		int id = Integer.parseInt(input("contentId"));
		String co = input("content");
		Content content = new Content();
		content.setId(id);
		content.setContent(co);
		contentJdbc.update(content);
		this.redirect("/admin/article/content.ac?id="+id);
	}

}
